package com.beiing.tianshuai.tianshuai.message.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.entity.ConsumeMarksBean;
import com.beiing.tianshuai.tianshuai.entity.NewFriendMessageBean;
import com.beiing.tianshuai.tianshuai.message.model.NewFriendMessageModel;
import com.beiing.tianshuai.tianshuai.message.model.NewFriendMessageModelImpl;
import com.beiing.tianshuai.tianshuai.message.view.NewFriendMessageViewImpl;

/**
 * Created by Jinni on 2017/8/8 0008.
 */

public class NewFriendMessagePresenter extends BasePresenter implements NewFriendMessagePresenterImpl, NewFriendMessageModel.OnRequestListener{

    private NewFriendMessageModelImpl       mModel;
    private NewFriendMessageViewImpl        mView;

    public NewFriendMessagePresenter(NewFriendMessageViewImpl view) {
        mView = view;
        mModel = new NewFriendMessageModel(this);
    }

    @Override
    public void getNewFriendMessage(String uid) {
        mView.showProgress();
        mModel.getNewFriendMessage(uid);
    }

    @Override
    public void getRefuseAddFriend(String id, String fromId, String toId) {
        mView.showProgress();
        mModel.getRefuseAddFriend(id, fromId, toId);
    }

    @Override
    public void getAgreeAddFriend(String id, String fromId, String toId) {
        mView.showProgress();
        mModel.getAgreeAddFriend(id, fromId, toId);
    }

    @Override
    public void consumeNewFriendsMarks(String uid) {
        mModel.consumeNewFriendsMarks(uid);
    }

    @Override
    public void onSuccess(NewFriendMessageBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onAgreeSuccess(CommonBean bean, String fromId) {
        mView.hideProgress();
        mView.getAgree(bean, fromId);
    }

    @Override
    public void onRefuseSuccess(CommonBean bean, String fromId) {
        mView.hideProgress();
        mView.getRefuse(bean, fromId);
    }

    @Override
    public void onConsumeSuccess(ConsumeMarksBean bean) {
        //View不用操作
    }

    @Override
    public void onError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }
}
